#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QxtWindowSystem>
#include <QString>
#include <QProcess>
#include <QDebug>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;

}

void MainWindow::displayActiveTitle(){
    QString sTit = QxtWindowSystem::windowTitle(QxtWindowSystem::activeWindow());
    ui->label->setText(sTit);
}

void MainWindow::testmanageWindows(){
    //sleep (5);
    this->hide();
    /*QString sTit = QxtWindowSystem::windowTitle(QxtWindowSystem::activeWindow());
    ui->label->setText(sTit);*/
    sleep (5);
    this->show();
    this->showNormal();
    this->activateWindow();
}

void MainWindow::testProcess(){
    //QString cmd = "xwininfo -id $(xdotool getactivewindow)";
    QProcess *myProcess = new QProcess(this);
    QString film = QString::fromUtf8("/home/emugwaneza/Vidéos/Babysitters (2007) Dra.avi");
    myProcess->start("smplayer",QStringList() <<film);
    /*if (!myProcess.waitForFinished(-1))
         qDebug() << "Make failed:" << myProcess.errorString();
     else
         qDebug() << "Make output:" << myProcess.readAll();*/
}

void MainWindow::on_pushButton_clicked()
{
   testProcess();
   sleep(10);
   displayActiveTitle();
}
